import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
state: {
	// 当前音频播放转态
	playerData:"",
	playUrl:"",//当前播放歌曲封面
	lyricArr:[],
	playList:[],//当前播放列表
	playIndex:null,//当前播放音频下标
	Mp3Lrc:[],//当前播放音频歌词
	musicData:{
	// 当前播放歌曲详情
		al:{},
	},
	currentTime:0,
	currentDuration:0,

	},
mutations: {
	setMp3data(state,data){
	state.musicData = data;
	// window.console.log(state.musicData);
	},
	setUrldata(state,data){
	state.playUrl = data;  
	// window.console.log(state.playUrl);
	},
	changePlayerState(state,type){//修改音频状态
	// console.log(type)
	state.playerData=type;
	},
	setPlaySongList(state,listId){//更新播放列表
	// console.log(listId)
	state.playList = listId;
	},
	setMp3Lrc(state,playlrc){
		state.Mp3Lrc = playlrc;
		// window.console.log(playlrc)
	},
	setPlayId(state,playIdx){
	// console.log(playIdx)
	state.playIndex = playIdx;
	},
	preSong(state){
		if(state.playIndex == 0){
		state.playIndex = state.playList.length-1;
		}else{
		state.playIndex--;
		}
	},
	nextSong(state){
	
	if(state.playIndex == state.playList.length-1){
		state.playIndex = 0;
	}else{
		state.playIndex++;
	}
	},
	getCurrentTime(state,data){
		this.state.currentTime = data.curTime;
		this.state.currentDuration = data.curDuration;
	}
}, 
  actions: {
  },
  modules: {
  }
})
